﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;
using ET;
namespace Presentation.Page
{
    public partial class Confirm_Mail : System.Web.UI.Page
    {
        #region[Define]
        private DataTable dtAssetRepair_Detail_Edit;
        private BLL_AssetRepairHeade clsAssetRepair = new BLL_AssetRepairHeade();
        #endregion

        #region[Controller]
        protected void Page_Load(object sender, EventArgs e)
        {
            int id;
            if (Int32.TryParse(Request.Params["id"], out id))
            {
                if (!IsPostBack)
                {
                    Confirm(int.Parse(Request.Params["id"].ToString()));
                }
            }
        }
        protected void cmdConfirm_Click(object sender, EventArgs e)
        {
            Confirm_btn();
        }
        protected void cmdCancel_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region[Function]
        protected void Confirm(int id)
        {
            dtAssetRepair_Detail_Edit = clsAssetRepair.BindGirdAssetRepairHeader_Detail_Edit(id);
            if (dtAssetRepair_Detail_Edit != null && dtAssetRepair_Detail_Edit.Rows.Count > 0)
            {
                lbID.Text = dtAssetRepair_Detail_Edit.Rows[0]["STT"].ToString();
                lbStt.Text = dtAssetRepair_Detail_Edit.Rows[0]["Status"].ToString();
            }
        }
        protected void Confirm_btn()
        {
            if (lbStt.Text == "1")
            {
                lbThongBaoLoi.Text = "Mẫu tin này đã duyệt rồi !";
            }
            else
            {
                ET.AssetRepairHeader obj = new AssetRepairHeader();
                obj.RowID = int.Parse(lbID.Text);
                obj.Status = 1;
                BLL.BLL_AssetRepairHeade.Review(obj);
                lbThongBaoLoi.Text = "Xác nhân mail cho mẫu tin thành công !";
            }
        }
        #endregion
    }
}